# Makefile for bison
# etu, to every rule it is inserted *.c, didn't
# know how to compile them otherwise
# usage:	make SYSTEM=(SYS5|BSD)

# where the installed binary goes
BINDIR = /usr/local/lbin

# where the parsers go
PARSERDIR = /usr/lib/bison

# names of parser files
PFILE = bison.simple
PFILE1 = bison.hairy

# It is unwise ever to compile a program without symbols.
CFLAGS = -g

PFILES = -DXPFILE=\"$(PARSERDIR)/$(PFILE)\" \
	 -DXPFILE1=\"$(PARSERDIR)/$(PFILE1)\"

OBJECTS = LR0.o allocate.o closure.o conflicts.o derives.o files.o	\
	  getargs.o gram.o lalr.o					\
	  lex.o main.o nullable.o output.o print.o reader.o symtab.o	\
	  warshall.o

start: bison

clean:
	rm -f *.o core

install: bison
# without install
	cp bison $(BINDIR)
	strip $(BINDIR)/bison
	chmod 755 $(BINDIR)/bison
	chown bin $(BINDIR)/bison
	chgrp bin $(BINDIR)/bison
	cp $(PFILE) $(PFILE1) $(PARSERDIR)
	chmod 644 $(PARSERDIR)/$(PFILE) $(PARSERDIR)/$(PFILE1)
	chown bin $(PARSERDIR)/$(PFILE) $(PARSERDIR)/$(PFILE1)
	chgrp bin $(PARSERDIR)/$(PFILE) $(PARSERDIR)/$(PFILE1)
# with install (bsd)
#	install bison $(BINDIR)
#	install -c $(PFILE) $(PFILE1) $(PARSERDIR)

bison: $(OBJECTS)
	$(CC) -g -o bison $(OBJECTS)

# This file is different to pass the parser file names
# to the compiler.
files.o: files.c files.h new.h gram.h
	$(CC) -c $(CFLAGS) $(PFILES) files.c

tar:
	tar -cf bison.tar $(PFILE) $(PFILE1) COPYING LR0.c MIAU Makefile \
	 allocate.c bison.hairy bison.simple closure.c conflicts.c \
	 derives.c files.c files.h getargs.c gram.c gram.h lalr.c \
	 lex.c lex.h machine.h main.c new.h nullable.c output.c print.c \
	 reader.c references state.h symtab.c symtab.h types.h \
	 warshall.c
	compress -f bison.tar

LR0.o: machine.h new.h gram.h state.h LR0.c
closure.o: machine.h new.h gram.h closure.c
conflicts.o: machine.h new.h files.h gram.h state.h conflicts.c
derives.o: new.h types.h gram.h derives.c
getargs.o: files.h getargs.c
lalr.o: machine.h types.h state.h new.h gram.h lalr.c
lex.o: files.h symtab.h lex.h lex.c
main.o: machine.h main.c
nullable.o: types.h gram.h new.h nullable.c
output.o: machine.h new.h files.h gram.h state.h output.c
print.o: machine.h new.h files.h gram.h state.h print.c
reader.o: files.h new.h symtab.h lex.h gram.h reader.c
symtab.o: new.h symtab.h gram.h symtab.c
warshall.o: machine.h warshall.c
# etu, the following added
allocate.o: allocate.c
files.o: files.c
gram.o: gram.c
